package peterka.ecka.model;

/**
 *
 * @author mpeterka
 */
public class EItem {

    private String code;
    private String name;
    private int dangerScore = 0;
    private boolean safe = false;
    private boolean healthDanger = false;
    private boolean animal = false;
    private boolean noChild = false;
    private boolean allergy = false;
    private boolean banned = false;

    public boolean isAllergy() {
        return allergy;
    }

    public void setAllergy(boolean allergy) {
        this.allergy = allergy;
    }

    public boolean isAnimal() {
        return animal;
    }

    public void setAnimal(boolean animal) {
        this.animal = animal;
    }

    public boolean isBanned() {
        return banned;
    }

    public void setBanned(boolean banned) {
        this.banned = banned;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public int getDangerScore() {
        return dangerScore;
    }

    public void setDangerScore(int dangerScore) {
        this.dangerScore = dangerScore;
    }

    public boolean isHealthDanger() {
        return healthDanger;
    }

    public void setHealthDanger(boolean healthDanger) {
        this.healthDanger = healthDanger;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isNoChild() {
        return noChild;
    }

    public void setNoChild(boolean noChild) {
        this.noChild = noChild;
    }

    public boolean isSafe() {
        return safe;
    }

    public void setSafe(boolean safe) {
        this.safe = safe;
    }

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final EItem other = (EItem) obj;
        if ((this.code == null) ? (other.code != null) : !this.code.equals(other.code)) {
            return false;
        }
        return true;
    }

    public int hashCode() {
        int hash = 7;
        hash = 53 * hash + (this.code != null ? this.code.hashCode() : 0);
        return hash;
    }

    public String toString() {
        return "EItem{" + ", code=" + code + ", name=" + name + ", dangerScore=" + dangerScore + ", safe=" + safe + ", healthDanger=" + healthDanger + ", animal=" + animal + ", noChild=" + noChild + ", allergy=" + allergy + ", banned=" + banned + '}';
    }

    public String format() {
        final String NL = "\n";
        StringBuffer sb = new StringBuffer(NL);

        sb.append("Kód přídatné látky: ");
        sb.append(getCode()).append(NL);

        sb.append("Název přídatné látky: ");
        sb.append(getName()).append(NL);

        sb.append("Skóre nebezpečnosti:  ");
        sb.append(getDangerScore()).append(NL);

        if (isSafe()) {
            sb.append(" * bezpečná přísada").append(NL);
        }

        if (isHealthDanger()) {
            sb.append(" * zdraví škodlivá přísada").append(NL);
        }

        if (isAnimal()) {
            sb.append(" * živočišný původ").append(NL);
        }

        if (isNoChild()) {
            sb.append(" * nevhodná pro děti").append(NL);
        }

        if (isAllergy()) {
            sb.append(" * způsobuje alergie").append(NL);
        }

        if (isBanned()) {
            sb.append(" * zakázaná přísada").append(NL);
        }

        return sb.toString();
    }
}
